package com.example.demo.page;

import com.example.demo.entity.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Controller
@RequestMapping("/")
public class Pages {

    @GetMapping({"", "index"})
    public String index(Model model) {
        log.info("index");
        List<UserInfo> userInfoList = new ArrayList<>();
        userInfoList.add(new UserInfo("Mike", 21));
        userInfoList.add(new UserInfo("Mio", 22));
        model.addAttribute("welcome", "Welcome!");
        model.addAttribute("userInfoList", userInfoList);
        return "index";
    }

    @GetMapping({"test", "xxx"})
    public String test() {
        log.info("test");
        return "test";
    }

}
